package com.itheima.cases.sets;

import java.util.HashSet;

public class Test {
    public static void main(String[] args) {
        // 测试无序 Set

        HashSet<Student> students = new HashSet<>();

        students.add(new Student("小明", 20));
        students.add(new Student("小明", 20));
        students.add(new Student("小明", 20));
        students.add(new Student("小明", 20));

        // 只比较对象的内存地址，只有内存地址不一致就保存
        students.forEach(student -> System.out.println(student));

        // 重写 equals和hashCode方法，使用对象的内容做比较
    }
}
